package cn.imvc.app.repositories;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.imvc.app.entities.Member;
import cn.imvc.app.entities.Orders;
import cn.imvc.data.jpa.repository.IJpqlExecutor;
import cn.imvc.data.jpa.repository.ISqlExecutor;

public interface OrdersRepository extends JpaRepository<Orders, Integer>,IJpqlExecutor<Orders>,ISqlExecutor<Object>{

	List<Orders> findAllByState(Byte state);
	
	@Modifying
	@Query("update Orders o set o.refundAmount = :refundAmount where o.id = :id")
	void updateRefundAmountById(@Param("refundAmount")int refundAmount,@Param("id")int id);

	List<Orders> findByMember(Member member);

	List<Orders> findByStateAndCreatedAtLessThan(Byte value, Date date);
}
